import defaultSettings from '@/settings'
import i18n from '@/lang'
import abp from 'abp'

export function getPageTitle(key) {
  const title = abp.setting.get('app.site.name') || defaultSettings.title || '加载中...';
  const hasKey = i18n.te(`route.${key}`)
  if (hasKey) {
    const pageName = i18n.t(`route.${key}`)
    return `${pageName} - ${title}`
  }
  return `${title}`
}

export function getRouteTitle(title) {
  const hasKey = i18n.te(`route.${title}`)
  if (hasKey) {
    const translatedTitle = i18n.t(`route.${title}`)
    return translatedTitle
  }
  return title
}
